/*
 * @Author: f
 * @Date: 2022-12-08 16:51:18
 * @Description: file content
 * @LastEditors: Chenx
 * @LastEditTime: 2023-03-20 17:11:38
 */
import { defineStore } from 'pinia'
interface UserInfoType  {
  securityAccountLink?: string
}
export const userStore = defineStore('user', {
  state() {
    return {
      token: 'tokenValue',
      userInfo: {}
    }
  },
  getters: {
    getToken(state: { token: string }): string {
      return state.token
    },
    getUserInfo(state: { userInfo: Object }): UserInfoType {
      return state.userInfo
    }
  },
  actions: {
    setToken(value: string) {
      this.token = value
    },
    setUserInfo(value: Object) {
      this.userInfo = value
    },
    resetUserInfo() {
      this.token = ''
      this.userInfo = {}
    }
  },
  persist: {
    enabled: true,
    strategies: [{ storage: sessionStorage, paths: ['token', 'userInfo'] }]
  }
})
